<html>
<head><meta charset="utf-8"><title>anon const in where bounds · project-const-generics · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/index.html">project-const-generics</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds.html">anon const in where bounds</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="225824267"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/anon%20const%20in%20where%20bounds/near/225824267" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds.html#225824267">(Feb 10 2021 at 11:44)</a>:</h4>
<p>An anonymous constant can assume that its parents where-bounds hold.<br>
As we can use anonymous constants inside of a where-bound this isn't actually always true rn.</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="cp">#![feature(const_generics, const_evaluatable_checked)]</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span><span class="k">where</span><span class="w"></span>
<span class="w">    </span><span class="p">[</span><span class="kt">u8</span><span class="p">;</span><span class="w"> </span><span class="n">std</span>::<span class="n">mem</span>::<span class="n">size_of</span>::<span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()]</span>: <span class="nb">Sized</span><span class="p">,</span><span class="w"></span>
<span class="p">{}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">foo</span>::<span class="o">&lt;</span><span class="p">[</span><span class="kt">i32</span><span class="p">]</span><span class="o">&gt;</span><span class="p">();</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>this currently emits the following errors:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="n">error</span><span class="p">[</span><span class="n">E0080</span><span class="p">]</span>: <span class="nc">evaluation</span><span class="w"> </span><span class="n">of</span><span class="w"> </span><span class="n">constant</span><span class="w"> </span><span class="n">value</span><span class="w"> </span><span class="n">failed</span><span class="w"></span>
<span class="w"> </span><span class="o">-</span>-&gt; <span class="nc">src</span><span class="o">/</span><span class="n">main</span><span class="p">.</span><span class="n">rs</span>:<span class="mi">4</span>:<span class="mi">10</span><span class="w"></span>
<span class="w">  </span><span class="o">|</span><span class="w"></span>
<span class="mi">4</span><span class="w"> </span><span class="o">|</span><span class="w">     </span><span class="p">[</span><span class="kt">u8</span><span class="p">;</span><span class="w"> </span><span class="n">std</span>::<span class="n">intrinsics</span>::<span class="n">size_of</span>::<span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()]</span>: <span class="nb">Sized</span><span class="p">,</span><span class="w"></span>
<span class="w">  </span><span class="o">|</span><span class="w">          </span><span class="o">^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^</span><span class="w"> </span><span class="n">size_of</span><span class="w"> </span><span class="n">called</span><span class="w"> </span><span class="n">on</span><span class="w"> </span><span class="kr">unsized</span><span class="w"> </span><span class="k">type</span> <span class="err">`</span><span class="p">[</span><span class="kt">i32</span><span class="p">]</span><span class="err">`</span><span class="w"></span>

<span class="n">error</span><span class="p">[</span><span class="n">E0277</span><span class="p">]</span>: <span class="nc">the</span><span class="w"> </span><span class="n">size</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">values</span><span class="w"> </span><span class="n">of</span><span class="w"> </span><span class="k">type</span> <span class="err">`</span><span class="p">[</span><span class="kt">i32</span><span class="p">]</span><span class="err">`</span><span class="w"> </span><span class="n">cannot</span><span class="w"> </span><span class="n">be</span><span class="w"> </span><span class="n">known</span><span class="w"> </span><span class="n">at</span><span class="w"> </span><span class="n">compilation</span><span class="w"> </span><span class="n">time</span><span class="w"></span>
<span class="w"> </span><span class="o">-</span>-&gt; <span class="nc">src</span><span class="o">/</span><span class="n">main</span><span class="p">.</span><span class="n">rs</span>:<span class="mi">8</span>:<span class="mi">11</span><span class="w"></span>
<span class="w">  </span><span class="o">|</span><span class="w"></span>
<span class="mi">3</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span><span class="k">where</span><span class="w"></span>
<span class="w">  </span><span class="o">|</span><span class="w">        </span><span class="o">-</span><span class="w"> </span><span class="n">required</span><span class="w"> </span><span class="n">by</span><span class="w"> </span><span class="n">this</span><span class="w"> </span><span class="n">bound</span><span class="w"> </span><span class="k">in</span><span class="w"> </span><span class="err">`</span><span class="n">foo</span><span class="err">`</span><span class="w"></span>
<span class="o">..</span><span class="p">.</span><span class="w"></span>
<span class="mi">8</span><span class="w"> </span><span class="o">|</span><span class="w">     </span><span class="n">foo</span>::<span class="o">&lt;</span><span class="p">[</span><span class="kt">i32</span><span class="p">]</span><span class="o">&gt;</span><span class="p">();</span><span class="w"></span>
<span class="w">  </span><span class="o">|</span><span class="w">           </span><span class="o">^^^^^</span><span class="w"> </span><span class="n">doesn</span><span class="o">'</span><span class="na">t</span><span class="w"> </span><span class="n">have</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="n">size</span><span class="w"> </span><span class="n">known</span><span class="w"> </span><span class="n">at</span><span class="w"> </span><span class="n">compile</span><span class="o">-</span><span class="n">time</span><span class="w"></span>
<span class="w">  </span><span class="o">|</span><span class="w"></span>
<span class="w">  </span><span class="o">=</span><span class="w"> </span><span class="n">help</span>: <span class="nc">the</span><span class="w"> </span><span class="k">trait</span><span class="w"> </span><span class="err">`</span><span class="nb">Sized</span><span class="err">`</span><span class="w"> </span><span class="n">is</span><span class="w"> </span><span class="n">not</span><span class="w"> </span><span class="n">implemented</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="err">`</span><span class="p">[</span><span class="kt">i32</span><span class="p">]</span><span class="err">`</span><span class="w"></span>
<span class="n">help</span>: <span class="nc">consider</span><span class="w"> </span><span class="n">relaxing</span><span class="w"> </span><span class="n">the</span><span class="w"> </span><span class="n">implicit</span><span class="w"> </span><span class="err">`</span><span class="nb">Sized</span><span class="err">`</span><span class="w"> </span><span class="n">restriction</span><span class="w"></span>
<span class="w">  </span><span class="o">|</span><span class="w"></span>
<span class="mi">3</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="n">T</span>: <span class="o">?</span><span class="nb">Sized</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span><span class="k">where</span><span class="w"></span>
<span class="w">  </span><span class="o">|</span><span class="w">         </span><span class="o">^^^^^^^^</span><span class="w"></span>

<span class="n">error</span>: <span class="nc">aborting</span><span class="w"> </span><span class="n">due</span><span class="w"> </span><span class="n">to</span><span class="w"> </span><span class="mi">2</span><span class="w"> </span><span class="n">previous</span><span class="w"> </span><span class="n">errors</span><span class="p">;</span><span class="w"> </span><span class="mi">2</span><span class="w"> </span><span class="n">warnings</span><span class="w"> </span><span class="n">emitted</span><span class="w"></span>
</code></pre></div>



<a name="225824306"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/anon%20const%20in%20where%20bounds/near/225824306" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds.html#225824306">(Feb 10 2021 at 11:45)</a>:</h4>
<p>i think the first error really shouldn't happen here</p>



<a name="225824508"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/anon%20const%20in%20where%20bounds/near/225824508" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds.html#225824508">(Feb 10 2021 at 11:47)</a>:</h4>
<p>i really have to learn more about the type system <span aria-label="concerned" class="emoji emoji-1f615" role="img" title="concerned">:concerned:</span></p>



<a name="225826397"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/anon%20const%20in%20where%20bounds/near/225826397" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds.html#225826397">(Feb 10 2021 at 12:08)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="116009">@nikomatsakis</span> can we require some predicates to hold as a prerequisite before checking if another predicate holds?</p>
<p>from what I can tell that isn't easily possible rn</p>



<a name="225871334"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/anon%20const%20in%20where%20bounds/near/225871334" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds.html#225871334">(Feb 10 2021 at 16:59)</a>:</h4>
<p>That's not really possible</p>



<a name="225871352"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/anon%20const%20in%20where%20bounds/near/225871352" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds.html#225871352">(Feb 10 2021 at 17:00)</a>:</h4>
<p>Is your concern about the first error that it's a user diagnostics fail</p>



<a name="225871387"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/anon%20const%20in%20where%20bounds/near/225871387" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds.html#225871387">(Feb 10 2021 at 17:00)</a>:</h4>
<p>Or something else</p>



<a name="225871503"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/anon%20const%20in%20where%20bounds/near/225871503" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds.html#225871503">(Feb 10 2021 at 17:00)</a>:</h4>
<p>I should say it's not possible <em>right now</em>, yeah</p>



<a name="225871530"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/anon%20const%20in%20where%20bounds/near/225871530" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds.html#225871530">(Feb 10 2021 at 17:00)</a>:</h4>
<p>It's probably not the approach I would take anyway</p>



<a name="225871904"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/anon%20const%20in%20where%20bounds/near/225871904" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds.html#225871904">(Feb 10 2021 at 17:03)</a>:</h4>
<p>the first error is caused because we execute an anon const while its caller bounds don't actually hold</p>



<a name="225872086"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/anon%20const%20in%20where%20bounds/near/225872086" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds.html#225872086">(Feb 10 2021 at 17:04)</a>:</h4>
<p>so while typechecking <code>std::mem::size_of::&lt;T&gt;()</code> in the above example we assume <code>T: Sized</code> to hold which isn't actually true when executing <code>std::mem::size_of::&lt;T&gt;()</code> later on</p>



<a name="225872849"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/anon%20const%20in%20where%20bounds/near/225872849" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds.html#225872849">(Feb 10 2021 at 17:09)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="cp">#![feature(const_generics, const_evaluatable_checked)]</span><span class="w"></span>

<span class="k">trait</span><span class="w"> </span><span class="n">Foo</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">type</span> <span class="nc">Assoc</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="k">const</span><span class="w"> </span><span class="n">ASSOC</span>: <span class="o">&lt;</span><span class="bp">Self</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="n">Foo</span><span class="o">&gt;</span>::<span class="n">Assoc</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">impl</span><span class="w"> </span><span class="n">Foo</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="kt">i32</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">type</span> <span class="nc">Assoc</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kt">i64</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="k">const</span><span class="w"> </span><span class="n">ASSOC</span>: <span class="kt">i64</span> <span class="o">=</span><span class="w"> </span><span class="mi">3</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">const</span><span class="w"> </span><span class="k">fn</span> <span class="nf">bar</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">(</span><span class="n">x</span>: <span class="nc">T</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="kt">usize</span> <span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">std</span>::<span class="n">mem</span>::<span class="n">forget</span><span class="p">(</span><span class="n">x</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="mi">3</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span><span class="k">where</span><span class="w"></span>
<span class="w">    </span><span class="n">T</span>: <span class="nc">Foo</span><span class="o">&lt;</span><span class="n">Assoc</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">T</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="p">[</span><span class="kt">u8</span><span class="p">;</span><span class="w"> </span><span class="n">bar</span>::<span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">(</span><span class="o">&lt;</span><span class="n">T</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="n">Foo</span><span class="o">&gt;</span>::<span class="n">ASSOC</span><span class="p">)]</span>: <span class="nb">Sized</span><span class="p">,</span><span class="w"></span>
<span class="p">{}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">foo</span>::<span class="o">&lt;</span><span class="kt">i32</span><span class="o">&gt;</span><span class="p">();</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="225872976"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/anon%20const%20in%20where%20bounds/near/225872976" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds.html#225872976">(Feb 10 2021 at 17:10)</a>:</h4>
<p>and we can't really deal with the caller bounds being incorrect</p>



<a name="225873454"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/anon%20const%20in%20where%20bounds/near/225873454" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds.html#225873454">(Feb 10 2021 at 17:13)</a>:</h4>
<p>this example causes an ice during const eval:</p>
<div class="codehilite"><pre><span></span><code>error: internal compiler error: /rustc/097bc6a84f2280a889b9ab4b544f27851a978927/compiler/rustc_middle/src/ty/consts/int.rs:228:13: expected int of size 4, but got size 8
</code></pre></div>



<a name="225873551"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/anon%20const%20in%20where%20bounds/near/225873551" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds.html#225873551">(Feb 10 2021 at 17:14)</a>:</h4>
<p>I was about to ask if this was actually problematic but then bam ICE <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="225874585"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/anon%20const%20in%20where%20bounds/near/225874585" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds.html#225874585">(Feb 10 2021 at 17:21)</a>:</h4>
<p>tbh I am really surprised that I've never thought of this before today <span aria-label="shock" class="emoji emoji-1f628" role="img" title="shock">:shock:</span> this feels like such a fundamental issue to me now</p>



<a name="225874606"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/anon%20const%20in%20where%20bounds/near/225874606" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds.html#225874606">(Feb 10 2021 at 17:21)</a>:</h4>
<p>^^"</p>



<a name="225981348"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/anon%20const%20in%20where%20bounds/near/225981348" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds.html#225981348">(Feb 11 2021 at 12:13)</a>:</h4>
<p>isn't this just one of the problems where we execute const eval without running typeck first?</p>



<a name="225981426"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/anon%20const%20in%20where%20bounds/near/225981426" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds.html#225981426">(Feb 11 2021 at 12:14)</a>:</h4>
<p>like... if we changed the ICE to a (potentially silent?) error, everything would just work and put out the correct error</p>



<a name="225981651"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/anon%20const%20in%20where%20bounds/near/225981651" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds.html#225981651">(Feb 11 2021 at 12:16)</a>:</h4>
<p><span class="user-mention silent" data-user-id="124288">oli</span> <a href="#narrow/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds/near/225981348">said</a>:</p>
<blockquote>
<p>isn't this just one of the problems where we execute const eval without running typeck first?</p>
</blockquote>
<p>do we want to guard mir building and ctfe again this though?</p>



<a name="225982843"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/anon%20const%20in%20where%20bounds/near/225982843" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds.html#225982843">(Feb 11 2021 at 12:29)</a>:</h4>
<p><span class="user-mention silent" data-user-id="124288">oli</span> <a href="#narrow/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds/near/225981348">said</a>:</p>
<blockquote>
<p>isn't this just one of the problems where we execute const eval without running typeck first?</p>
</blockquote>
<p>do we already have an issue for this?</p>



<a name="225982935"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/anon%20const%20in%20where%20bounds/near/225982935" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds.html#225982935">(Feb 11 2021 at 12:30)</a>:</h4>
<p>i already heard about that before but at that time it sounded to me like this is something we wanted to fix</p>



<a name="225983476"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/anon%20const%20in%20where%20bounds/near/225983476" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds.html#225983476">(Feb 11 2021 at 12:35)</a>:</h4>
<p>Kind of, the only one I found was <a href="https://github.com/rust-lang/rust/issues/79047">https://github.com/rust-lang/rust/issues/79047</a> but I know there's another more general one</p>



<a name="225983582"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/anon%20const%20in%20where%20bounds/near/225983582" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds.html#225983582">(Feb 11 2021 at 12:36)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/issues/69487">https://github.com/rust-lang/rust/issues/69487</a></p>



<a name="225984666"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/anon%20const%20in%20where%20bounds/near/225984666" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds.html#225984666">(Feb 11 2021 at 12:48)</a>:</h4>
<p>hmm, yeah <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span> these cases seem weird to me and i expect us to never try and evaluate these consts</p>



<a name="225984733"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/anon%20const%20in%20where%20bounds/near/225984733" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds.html#225984733">(Feb 11 2021 at 12:49)</a>:</h4>
<p>there have been multiple attempts at fixing that, but I've never scheduled the time to really dig into it</p>



<a name="225984814"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/anon%20const%20in%20where%20bounds/near/225984814" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds.html#225984814">(Feb 11 2021 at 12:50)</a>:</h4>
<p>i think i am going to take some time this weekend to look into this</p>



<a name="225984823"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/anon%20const%20in%20where%20bounds/near/225984823" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds.html#225984823">(Feb 11 2021 at 12:50)</a>:</h4>
<p>we have some superficial checks, but out of some reason not every typeck failure registers in <code>TypeckResults</code></p>



<a name="225984894"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/anon%20const%20in%20where%20bounds/near/225984894" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds.html#225984894">(Feb 11 2021 at 12:51)</a>:</h4>
<p>can we just add a global per query state to <code>TyCtxt</code></p>



<a name="225984923"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/anon%20const%20in%20where%20bounds/near/225984923" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds.html#225984923">(Feb 11 2021 at 12:51)</a>:</h4>
<p>so we add a flag <code>did_error</code> to queries</p>



<a name="225984993"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/anon%20const%20in%20where%20bounds/near/225984993" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds.html#225984993">(Feb 11 2021 at 12:52)</a>:</h4>
<p>which is <code>true</code> if we hit an while evaluating a query</p>



<a name="225984998"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/anon%20const%20in%20where%20bounds/near/225984998" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds.html#225984998">(Feb 11 2021 at 12:52)</a>:</h4>
<p>and we read at the end of <code>typeck</code></p>



<a name="225985038"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/anon%20const%20in%20where%20bounds/near/225985038" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds.html#225985038">(Feb 11 2021 at 12:52)</a>:</h4>
<p><span class="user-mention silent" data-user-id="124288">oli</span> <a href="#narrow/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds/near/225984823">said</a>:</p>
<blockquote>
<p>we have some superficial checks, but out of some reason not every typeck failure registers in <code>TypeckResults</code></p>
</blockquote>
<p>ah, that makes sense to me</p>



<a name="225985206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/anon%20const%20in%20where%20bounds/near/225985206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds.html#225985206">(Feb 11 2021 at 12:54)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds/near/225984993">said</a>:</p>
<blockquote>
<p>which is <code>true</code> if we hit an while evaluating a query</p>
</blockquote>
<p>haha omg, that would be a game changer</p>



<a name="225985250"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/anon%20const%20in%20where%20bounds/near/225985250" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds.html#225985250">(Feb 11 2021 at 12:54)</a>:</h4>
<p>i thought about that for whether we want to normalize constants in queries</p>



<a name="225985272"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/anon%20const%20in%20where%20bounds/near/225985272" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds.html#225985272">(Feb 11 2021 at 12:55)</a>:</h4>
<p>just add some flags in the <code>TyCtxt</code> we set during queries</p>



<a name="225985290"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/anon%20const%20in%20where%20bounds/near/225985290" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds.html#225985290">(Feb 11 2021 at 12:55)</a>:</h4>
<p>which allows us to keep queries pure</p>



<a name="225985314"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/anon%20const%20in%20where%20bounds/near/225985314" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds.html#225985314">(Feb 11 2021 at 12:55)</a>:</h4>
<p>while still having easy ways to deal with stuff like this</p>



<a name="225985477"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/anon%20const%20in%20where%20bounds/near/225985477" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds.html#225985477">(Feb 11 2021 at 12:57)</a>:</h4>
<p>so similar to <code>TyCtxtAt</code> we'd have a <code>TyCtxtNormalizeConsts</code>?</p>



<a name="225985532"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/anon%20const%20in%20where%20bounds/near/225985532" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds.html#225985532">(Feb 11 2021 at 12:57)</a>:</h4>
<p>probably just</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">struct</span> <span class="nc">GlobalCtxt</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="c1">// ...</span>
<span class="w">    </span><span class="n">normalize_consts</span>: <span class="nc">Cell</span><span class="o">&lt;</span><span class="kt">bool</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="225985603"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/anon%20const%20in%20where%20bounds/near/225985603" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/anon.20const.20in.20where.20bounds.html#225985603">(Feb 11 2021 at 12:58)</a>:</h4>
<p>which we modify whenever we enter a new query</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>